package br.gov.capgov.treinamento.jpa.entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@NamedQuery(name="Url.findAll", query="SELECT q FROM Url q")
public class Url implements Serializable
{
	private static final long serialVersionUID = 1L; 
 
	@Id
	@SequenceGenerator(name="URL_ID_GENERATOR", sequenceName="URL_ID_SEQ", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="URL_ID_GENERATOR")
	private Integer id;

	@Column(name="nome_url")
	private String nomeUrl;
	
	@Column(name="disponivel") 
	private boolean disponivel;
	
	@ManyToOne
	@JoinColumn(name="sistema_id", referencedColumnName="id")
	private Sistema sistema;
	
	@OneToMany(mappedBy="url",  cascade = CascadeType.REMOVE)
	List <InfoUrl> infoUrls1;
	
	@OneToMany(mappedBy="url", cascade = CascadeType.REMOVE)
	List<ControleDeQuedas> controleDeQuedas1;
	
	@Transient
	@Temporal(value=TemporalType.TIMESTAMP)
	private Date dataAtual;
	
	@Transient
	List <InfoUrl> infoUrls;
	
	@Transient
	List<ControleDeQuedas> controleDeQuedas;
	
	@Transient
	private int totalQuedas;

	public Url()
	{	
	}

	public Integer getId()
	{
		return id;
	}
	public void setId(Integer id)
	{
		this.id = id;
	}
	public String getNomeUrl()
	{
		return nomeUrl;
	}
	public void setNomeUrl(String nomeUrl)
	{
		this.nomeUrl = nomeUrl;
	}
	public boolean isDisponivel()
	{
		return disponivel;
	}
	public void setDisponivel(boolean disponivel)
	{
		this.disponivel = disponivel;
	}
	public Sistema getSistema()
	{
		return sistema;
	}
	public void setSistema(Sistema sistema)
	{
		this.sistema = sistema;
	}
	public List<InfoUrl> getInfoUrls()
	{
		return infoUrls;
	}
	public void setInfoUrls(List<InfoUrl> infoUrls)
	{
		this.infoUrls = infoUrls;
	}
	public List<ControleDeQuedas> getControleDeQuedas()
	{
		return controleDeQuedas;
	}
	public void setControleDeQuedas(List<ControleDeQuedas> controleDeQuedas)
	{
		this.controleDeQuedas = controleDeQuedas;
	}
	public Date getDataAtual()
	{
		return dataAtual;
	}
	public void setDataAtual(Date dataAtual)
	{
		this.dataAtual = dataAtual;
	}
	public int getTotalQuedas()
	{
		return totalQuedas;
	}
	public void setTotalQuedas(int totalQuedas)
	{
		this.totalQuedas = totalQuedas;
	}		
}